import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @Description 
 * @author Jerry
 * @date 2016-08-08
 */
public class TestServlet extends HttpServlet {
    private static final long serialVersionUID = -4864823605669975406L;

    @Override
    public  void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        outChineseByOutPutStream(resp);
    }

    public void outChineseByOutPutStream(HttpServletResponse response) throws IOException{
        String data ="中国";
        OutputStream out = response.getOutputStream();
        response.setHeader("content-type","text/html;charset=UTF-8");
        byte[] batesize = data.getBytes("utf-8");
        out.write(batesize);
        out.close();

    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
